package threadLearn;

public class demon6 {
    private static int count=0;
    private  int a=10;
    private static Object  object=new Object();
    public static void main(String[] args) throws InterruptedException {
        demon6 demon6=new demon6();
        Thread thread=new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                synchronized(object){
                    count++;
                    demon6.a++;
                }


            }
        });
        Thread thread1=new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                synchronized(object){
                    count++;
                }
            }
        });
        thread1.start();
        thread.start();
        thread.join();
        thread1.join();
        System.out.println(count);
    }
    public void func1(){
        Runnable r=()->{
            System.out.println(a);
        };

    }
}
